import { UserEntity } from "./user.entity";
import { getModelForClass, index, modelOptions, Prop, ReturnModelType, Severity } from '@typegoose/typegoose';
import BaseEntity from "../common/base.entity";

@modelOptions({ schemaOptions: { collection: 'token' }, options: { allowMixed: Severity.ALLOW } })
@index({ token: 1 })
export class TokenEntity extends BaseEntity {
  @Prop()
  secret?: string;

  @Prop({ required: true })
  token!: string;

  @Prop()
  expires_in!: number;

  @Prop()
  user!: UserEntity;
}
export const TokenModel: ReturnModelType<typeof TokenEntity> = getModelForClass(TokenEntity);
